package Student;

import java.util.ArrayList;

public class Student extends Person {
    private long number;
    private int phi;
    private int eng;
    private int comp;

    public Student(String name, String sex, long number, int phi, int eng, int comp) {
        super(name, sex);
        this.number = number;
        this.phi = phi;
        this.eng = eng;
        this.comp = comp;
    }

    public Student() {
    }

    public double aver() {
        return (phi + eng + comp) / 3.0;
    }

    public ArrayList compare(){
        ArrayList<Integer> score = new ArrayList<>();
        score.add(phi);
        score.add(eng);
        score.add(comp);
        score.sort((o1, o2) -> o2 - o1);
        return score;
    }
    public int max() {
        return  (int)compare().get(0);
    }

    public int min() {
        return  (int)compare().get(2);
    }

    @Override
    public String toString() {
        return "学号=" + number +
                super.toString() +
                ", 平均分=" + aver() +
                ", 最大分=" + max() +
                ", 最小分=" + min();
    }
}
